
 begintownscript;

 variables;

 int i,j,k,r1,choice;

 body;

 beginstate INIT_STATE;

	if (get_flag(7,0) == 0) {
		message_dialog("It's obvious the administrators of Faerengrove haven't been doing their jobs. A well-run Empire town wouldn't tolerate stray lizards, let alone a large tower inhabited by a vampire, this close to human settlement.","The tower is gloomy, not a single window can be found. No doubt to prevent the sunlight entering the tower.");
		set_flag(7,0,1);
}

	if ((get_flag(8,1) == 5) && (get_flag(8,6) == 1)) {
		play_sound(108);
		play_sound(108);
		play_sound(108);
		message_dialog("Loud crashes are coming from the upper part of the tower. The roof finally crashed completely. You were lucky to get out.","With their master gone the undead in the tower have crumbled into piles of dust. There isn't much for you to do here anymore.");
		set_flag(8,6,2);
		set_terrain(26,14,126);
		set_terrain(26,13,127);
		set_terrain(26,12,127);
		set_height(26,14,5);
		set_height(26,13,5);
		set_height(26,12,5);
}

	if (get_flag(8,6) == 2)
		set_terrain(26,14,126);


	if (get_flag(7,15) == 1)
		erase_char(6);

	set_name(6,"Mosadorl");

	set_crime_tolerance(1);

break;

 beginstate START_STATE;

	if (get_ran(1,0,100) < 6)
		text_bubble_on_char(6,"Do not fear.");
	if (get_ran(1,0,100) < 6)
		text_bubble_on_char(6,"Speak with me mortal.");

	if ((has_special_item(9)) && (char_ok(6) == TRUE) && (get_flag(7,11) == 0)) {
		relocate_character(6,25,19);
		set_character_facing(6,0);
		begin_talk_mode(25);
}
break;

 beginstate EXIT_STATE;

break;

 beginstate 10;
	move_to_new_town(8,16,6);
break;

 beginstate 11;
	if (get_flag(7,1) == 0) {
		message_dialog("You step inside the tower. You immediately spot undead, however, they do not seem to care for you. They do not focus their attention at you at all, in fact considering how mindless basic undead are, you think these were ordered not to harm you.","Why the commander of these undead would do so, remains a mystery. No doubt you will get an answer once you reach the master of the tower.");
		set_flag(7,1,1);
}
break;

 beginstate 12;
	if (get_flag(7,2) == 0) {
		message_dialog("You've entered what looks like a throne room. Ahead of you sits the master of this tower. He is indeed a vampire, but although he is no doubt centuries old, he looks like a young man.","The vampire rises from his throne. _Mortals! Do not unholster your weapons! I wish no harm unto you! Please, speak with me!_ You wait for a moment to see if a trap of some sort would be sprung. When nothing happens you approach the vampire.");
		set_flag(7,2,1);
}
break;

 beginstate 13;
	if (get_flag(7,3) == 0 && get_flag(7,15) == 0) {
		message_dialog("_Stay away from the door! You have no business there! Please, come speak with me._","");
		block_entry(1);
}

	if (get_flag(7,3) > 0 && get_flag(7,15) == 0) {
		message_dialog("_Please, do not go further. That doorway leads to my private chambers. Nothing concerns you there._","");
		block_entry(1);
}
break;

 beginstate 14;
	if (get_flag(7,4) == 0) {
		message_dialog("This room is littered with bones and skulls, all of which look extremely old. You think some of the skulls would crumble into dust if you touched them. Why would a vampire keep such low quality bones?","Perhaps this used to be some sort of emergency supply for skeletons, who knows?");
		set_flag(7,4,1);
}
break;

 beginstate 15;
	if (get_flag(7,5) == 0) {
		message_dialog("You enter a spiderweb-filled room. Clearing out the closest webs, you make out four caskets. Whatever the reason for their existence is, they certainly haven't been used for it.","");
		set_flag(7,5,1);
}
break;

 beginstate 16;
	if (get_flag(7,6) == 0) {
		message_dialog("This is, without question, a prison room. There are several cages for unfortunate victims, but no victims. In fact you do not detect a trace of dried blood, only layers of dust.","The cages must not be used frequently.");
		set_flag(7,6,1);
}
break;

 beginstate 17;
	if (get_flag(7,7) == 0) {
		message_dialog("You've entered what looks like some kind of blood draining room. There are puddles of blood everywhere, and a nasty looking zombie with a kitchen knife. You inspect the tables, there are chunks of meat on them.","The chunks do not look like they came from a human, but you can't be sure.");
		set_flag(7,7,1);
}
	if (get_flag(7,7) == 2) {
		message_dialog("It would seem that the cows are brought here, for slaughter. This is most strange. Vampires do not need food, apart from blood, so why would he keep cows?","");
		set_flag(7,7,7);
}
break;

 beginstate 18;
	if (get_flag(7,7) == 0) {
		message_dialog("That's odd. This looks like a kitchen with adjacent livestock. The cows are kept in a small pen, with obviously magical grass, there is no sunlight entering the room.","There's even a small cellar for foodstuffs, although upon looking at the cellar more closely, you see that it is, in fact, not filled with food, but with different cups and vessels for liquids.");
		set_flag(7,7,2);
}

	if (get_flag(7,7) == 1) {
		message_dialog("Apparently the blood didn't come from humans. There is a small pen, with grass growing in it and cows eating the grass. Why would a vampire want to farm cattle is beyond you. There is also a small cellar near the cow pen.","");
		set_flag(7,7,7);
}
break;

 beginstate 19;
	if (get_flag(7,8) == 0) {
		reset_dialog();
		add_dialog_str(0,"You find a closed book with a faint magical energy floating away from it. This could be the vampires personal spell book, so reading it could be dangerous.",0);
		add_dialog_str(1,"The temptation is hard nonetheless. You could open the book and see what it contains.",0);
		add_dialog_choice(0,"Read.");
		add_dialog_choice(1,"Ignore the Book.");
		choice = run_dialog(1);
}

	if ((choice == 1) && (get_skill_total(42) >= 50)) 
		set_state_continue(20);


	if ((choice == 1) && (get_skill_total(42) < 50))
		message_dialog("You open the book and start to read. The book contains mostly gruesome necromantic rituals and chants with nothing magical about them. You do, however, find one interesting ritual.","You try to decipher the runes, but alas they are too old, and too weird for you to make any sense out of them.");


 break;

 beginstate 20;
	message_dialog("You open the book and start to read. The book contains mostly gruesome necromantic rituals and chants with nothing magical about the. You do, however, find one interesting ritual.","After a long and arduous task, you manage to decipher the runes. The ritual helps you to improve your knowledge on the Summon Aid spell.");
	j = get_selected_pc();
	i = 0;
	while (i < 4) {
		if (((j < 0) || (j == i)) && (char_ok(i))) {
			if (get_spell_level(i,0,14) == 1)
				change_spell_level(i,0,14,1);
		}
		i = i + 1;
	}
	set_flag(7,8,1);
break;

 beginstate 21;
	if (char_ok(6) == TRUE && get_flag(7,11) == 0) {
		message_dialog("You shouldn't go through these doors. Mosadorl doesn't know you're here and it's best to keep things that way.","");
		block_entry(1);
}
 break;